﻿/*
    A gameboard must implement the following properties:
        Board - describes the game board being played
        value - a numeric value representing an indication of whether the board is favorable to the player (value>0) or not (value<0)

    A gameboard must implement the following methods:
        getValidMoves(model.row, model.column) - returns a collection of valid moves for the model at the indicated position
        isFinalState() - is true when the game is finished
        fromJSON(json) - returns a new gameboard set to the given json string created by JSON.stringify(gameboard)
        copyBoard(board.Board) - sets the current board with the given board's properties
        applyMove(move, player) - performs the given move for the specified player
*/

AzureGames.GameBoard = Class.extend ({    
    init: function () {
        this.created = new Date();
        this.lastUpdate = this.created;
        this.value = 0;
    },
    copyBoard: function () {
        // this should be overwritten in extended gameboard
    }
});

// returns a two dimensional array preset to given value
EmptyBoard = function (rows, columns, value) {    
    var a = new Array(rows);
    for (var i = 0; i < rows; i++) {
        a[i] = new Array(columns);
        for (var j = 0; j < columns; j++) {
            a[i][j] = value;  
        }
    }
    return (a);
};